var statusStore = Ext.create('Ext.data.Store',{
    fields : ['value', 'text'],
    data : [
            ['0', '启用']
            ,
            ['1', '禁用']
          ],
          id:'0'

  });
Ext.define('Admin.view.user.Detail', {
extend: 'Admin.view.Detail',
alias: 'widget.Userdetail',

bind: {
    title: '用户 - 【{theObj.id}】'
},

componentCls: 'user-detail',
bodyPadding: 0,

controller: 'detail',

afterRender: function(ct, position) {
this.callParent();
},
items: [{
listeners: {
render: function(p){
  p = p.getEl();
  var me= this.up();
  me.h0=p.getHeight();
  p.on('scroll', function(e, t){
      me.onscroll(t.scrollTop,t.clientHeight);
  }, p);
}
},
title: 'Panel 0',
frame: false,
xtype: 'container',
style: {
  overflow: 'auto'
},

items: [
    Admin.view.Detail.tbar,          
{
title : '用户信息',
margin : '0 0 10 0',
cls : 'nav_pos',
reference : 'formpanel',
xtype: 'formpanel',        
items: [{
    xtype: 'fieldset',
    defaults : {
            clearIcon: true,
            labelWidth: '35%',
            xtype:'textfield'
        },
items:[
{
label: '登陆用户名',
bind: '{theObj.loginName}',
allowBlank: false,
//远端重复验证
validator:function(val,fld){
var fld = this;
if(!val || val==''){
  fld.markInvalid("该输入项为必输项");
  return false;
}

Ext.Ajax.request({  
  params:{pn:'loginName',pv:val},  
  method:"GET",  
  //async:false,
  url:'/exists/User',  
  success:function(response,options){  
      if(response.responseText=='true'){//服务器端的返回值为'false'  
          fld.markInvalid("该用户名已经被占用!");
          return false;
      }else{
          fld.clearInvalid();
          return true;
      }
  }  
}); 
return true;
}
},	{
label: '姓名',
bind: '{theObj.name}',
allowBlank: false
}	]
},
{
    xtype: 'fieldset',
    defaults : {
            clearIcon: true,
            labelWidth: '35%',
            xtype:'textfield'
        },
items:[{
label: '明文密码',
bind: '{theObj.plainPassword}'
},	
{
label: '密码',
xtype:'textfield',
bind: '{theObj.password}',
allowBlank: false 
}]
},
{
    xtype: 'fieldset',
    defaults : {
            clearIcon: true,
            labelWidth: '35%',
            xtype:'textfield'
        },
items:[
 {
  label: '角色',
  bind: '{theObj.roles}',
  allowBlank: false,
  blankText: '该选项必选项',
  xtype: 'selectfield',
  triggerAction:'all',
  typeAhead :false,
  editable:false,
     minChars:1,
     lazyInit:false,
  queryParam : 'kw',
  valueField: 'name',
  displayField: 'name',
  store: Admin.Cfg.getDistinctStore('net.bat.entity.User','roles')
},	
{
label: '最近登陆时间',
xtype:'textfield',
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
bind: '{theObj.dt_lastlogin}'
}]
},
{
    xtype: 'fieldset',
    defaults : {
            clearIcon: true,
            labelWidth: '35%',
            xtype:'textfield'
        },
items:[
{
label: '注册时间',
xtype:'textfield',
renderer: Ext.util.Format.dateRenderer('m/d/Y'),
bind: '{theObj.registerDate}'
},{
label: '邮箱',
vtype : "email",// email格式验证
vtypeText : "不是有效的邮箱地址",// 错误提示信息
allowBlank : false,
//blankText: '邮箱不能为空',
bind: '{theObj.email}'
}	]
},	{
    xtype: 'fieldset',
    defaults : {
            clearIcon: true,
            labelWidth: '35%',
            xtype:'textfield'
        },
items:[
{
label: '状态',
allowBlank: false,
xtype: 'selectfield',
typeAhead :false,
editable:false,
triggerAction:'all',
minChars:1,
lazyInit:false,
queryParam : 'kw',
valueField: 'value',
displayField: 'text',
store:statusStore,
bind: '{theObj.status}'
}]
}]}]


}],
initComponent: function() {   
var rec = this.getViewModel().get('theObj');
var item = this.items[0].items[0].items[0].items[0];
//修改user，非add
if(rec.get('id')>0){
  item.xtype='textfield';
}else{
  item.xtype='textfield';
}
this.callParent(arguments);
}
});



